package com.ruoyi.system.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.system.service.IUserActiveCardRecordService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActivePrizeConfig;
import com.ruoyi.system.service.IActivePrizeConfigService;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/system/active/prize")
public class ActivePrizeController extends BaseController {


    @Autowired
    private IActivePrizeConfigService activePrizeConfigService;

    /**
     * 查询【组组乐盒子奖品】列表
     */
    @PreAuthorize("@ss.hasPermi('system:active:goods:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivePrizeConfig activePrizeConfig) {
        startPage();
        List<ActivePrizeConfig> list = activePrizeConfigService.selectActivePrizeConfigList(activePrizeConfig);
        return getDataTable(list);
    }

    /**
     * 获取【组组乐盒子奖品】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(activePrizeConfigService.selectActivePrizeConfigById(id));
    }

    /**
     * 新增【组组乐盒子奖品】
     */
    @PreAuthorize("@ss.hasPermi('system:active:goods:add')")
    @Log(title = "【新增组组乐盒子奖品】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivePrizeConfig activePrizeConfig) {
        return toAjax(activePrizeConfigService.insertActivePrizeConfig(activePrizeConfig));
    }

    /**
     * 修改【组组乐盒子奖品】
     */
    @PreAuthorize("@ss.hasPermi('system:active:goods:edit')")
    @Log(title = "【修改组组乐盒子奖品】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivePrizeConfig activePrizeConfig) {
        return toAjax(activePrizeConfigService.updateActivePrizeConfig(activePrizeConfig));
    }

    /**
     * 删除【组组乐盒子奖品】
     */
    @PreAuthorize("@ss.hasPermi('system:active:goods:del')")
    @Log(title = "【删除组组乐盒子奖品】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(activePrizeConfigService.deleteActivePrizeConfigByIds(ids));
    }
}
